package com.android.equipment.ui.dialog

import android.content.Context
import com.android.equipment.R
import com.android.equipment.databinding.DialogCreateWorkBinding
import com.lxj.xpopup.core.CenterPopupView

class CreateWorkDialog(context: Context,listener: OnConfirmListener) : CenterPopupView(context) {
    lateinit var binding: DialogCreateWorkBinding
    private var listener: OnConfirmListener? = listener
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_create_work
    }

    override fun onCreate() {
        super.onCreate()
        binding = DialogCreateWorkBinding.bind(popupImplView)
        binding.tvConfirm.setOnClickListener{
            if(binding.etWorkName.text.toString().isNotEmpty()){
                dismiss()
                listener?.onConfirm(binding.etWorkName.text.toString())
            }else{
                binding.etWorkName.error = "请输入作业名称"
            }
        }
    }
      interface OnConfirmListener {
        fun onConfirm(name: String)
    }
}


